<template>
	<view style="padding: 20rpx;">
		<view class="list" v-for="(item,index) in list" :key="index" @click="godetails(item.id)">
			<view class="content">
				<view class="trash" @click.stop="gotrash(item.id)">
					<u-icon name="trash" color="#ffffff" size="16"></u-icon>
				</view>
				<view class="image">
					<image :src="item.logo" mode=""></image>
					<view class="card">
						{{item.labelTemp}}
					</view>
				</view>
				<view class="info">
					<view class="title">{{item.name || 'none'}}</view>
					<view class="mintitle">#{{item.categoryName || 'none'}}</view>
					<view class="rate">
						<view class="">
							<u-rate count="5" size="13" readonly v-model='value'></u-rate>
						</view>
						<view class="text">5</view>
					</view>
					<view class="address">
						<view class="image">
							<image src="/static/address.png" mode="widthFix"></image>
						</view>
						<view class="text">
							{{item.address|| 'none'}}
						</view>
					</view>
					<view class="distance">
						<view class="image">
							<image src="/static/distance.png" mode="widthFix"></image>
						</view>
						<view class="text">
							{{item.distance|| 'none'}}
						</view>
					</view>
					<view class="mu">
						<view class="image">
							<image src="/static/mu.png" mode=""></image>
						</view>
						<view class="text">
							{{item.showNum}}
						</view>
					</view>
				</view>
			</view>
			<view class="sj">
				<view class="sj-text">
					Register Date:{{item.openTime}}
				</view>
				<view class="sj-text">
					Expired Date:{{item.closeTime}}
				</view>
			</view>
		</view>
		<view v-show="list.length > 0" style="padding-bottom: 20rpx;">
			<u-loadmore :status="status" :nomore-text="nomoreText" fontSize="12" color="#999" />
		</view>
		<u-modal :show="show" :confirmText="confirmText" :cancelText="cancelText" :title="title" @confirm="confirm"
			@cancel="cancel" :showCancelButton="true" :content='content'></u-modal>
	</view>
</template>

<script>
	export default {
		name: "Showcaselist",
		data() {
			return {
				value: 5,
				status: 'nomore',
				nomoreText: 'The End',
				show: false,
				title: this.$t('user.prompt'),
				content: this.$t('user.delete'),
				cancelText: this.$t('user.cancel'),
				confirmText: this.$t('user.yes'),
				id: 0
			};
		},
		created() {
			console.log(this.list)
			if (this._i18n.locale == 'zh') {
				this.nomoreText = '没有更多了'
			} else {
				this.nomoreText = 'The End'
			}
		},
		props: {
			list: {
				type: Array,
				default: []
			},
		},
		methods: {
			godetails(id) {
				console.log(id)
				uni.navigateTo({
					url: '/pages/Business/details/index?id=' + id
				})
			},
			cancel() {
				this.show = false
			},
			gotrash(id) {
				this.id = id
				this.show = true
			},
			confirm() {
				uni.showLoading({
					mask: true
				})
				let params = {
					map: 'applet_city_post_delete',
					pid: this.id
				}
				this.$Request({
					method: 'GET',
					data: params
				}).then(res => {
					if (res.data.ec == 200) {
						uni.hideLoading()
						uni.showToast({
							title: this.$t('user.success'),
							icon: 'none'
						})
						this.$emit("userinfo", this.index)
						this.show = false
					} else {
						uni.hideLoading()
						this.show = false
						uni.showToast({
							title: this.$t('user.fail'),
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.list {
		margin-top: 20rpx;
		padding: 20rpx;
		background-color: #ffffff;

		border-radius: 10rpx;

		.content {
			display: flex;
			position: relative;

			.trash {
				padding: 5rpx 15rpx;
				background-color: #00aaff;
				position: absolute;
				right: 0;
				top: 20%;
				border-top-left-radius: 20rpx;
				border-bottom-left-radius: 20rpx;
			}
		}

		.mu {
			position: absolute;
			right: 20rpx;
			bottom: 0rpx;
			display: flex;
			align-items: center;

			.image {
				image {
					width: 25rpx;
					height: 20rpx;
				}
			}

			.text {
				margin-left: 5rpx;
				font-size: 24rpx;
				color: #999;
			}
		}

		.sj {
			display: flex;
			justify-content: space-between;
			border-radius: 5rpx;
			margin-top: 10rpx;

			.sj-text {
				background-color: #f8f8f8;
				width: 46%;
				padding: 2rpx 10rpx;
				color: #999;
				font-size: 24rpx;
			}
		}

		.info {
			margin-left: 20rpx;

			.address {
				height: 22rpx;
				display: flex;
				align-items: center;

				.image {
					image {
						width: 18rpx;

					}
				}

				.text {
					width: 80%;
					font-size: 24rpx;
					color: #999;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					-o-text-overflow: ellipsis;
					margin-left: 5rpx;
				}
			}

			.distance {
				height: 22rpx;
				display: flex;
				align-items: center;
				margin-top: 10rpx;

				.image {
					image {
						width: 18rpx;

					}
				}

				.text {
					width: 80%;
					font-size: 24rpx;
					color: #999;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					-o-text-overflow: ellipsis;
					margin-left: 5rpx;
				}
			}

			.mintitle {
				font-size: 24rpx;
				color: #00aaff;
				padding: 2rpx 10rpx;
				background-color: #f8f8f8;
				display: inline-block;
				border-radius: 20rpx;
			}

			.title {
				width: 500rpx;
				font-weight: 600;
				font-size: 28rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
			}

			.rate {
				display: flex;
				align-items: center;

				.text {
					font-size: 24rpx;
					color: red;
					margin-left: 5rpx;
				}
			}


		}

		.image {
			image {
				width: 110rpx;
				height: 110rpx;
				border-radius: 10rpx;
				margin-top: 10rpx;
			}
		}

		.card {
			background-color: #ff6378;
			border-radius: 30rpx;
			margin-top: 5rpx;
			font-size: 24rpx;
			color: #fff;
			text-align: center;
		}
	}
</style>
